// -*- coding: utf-8 -*- 
/**
 * Project: Java8InActionT
 *
 * @author: yanking
 * Create time: 2022-03-18 20:48
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.DesignPattern;

public class StrategyPattern {
    /**
     * 战略设计模式 -> 使用接口判断方法判断类型
     */
    public interface ValidateStrategy {
        boolean execute(String s);
    }

    static class IsAllLowerCaseStrategy implements ValidateStrategy {
        @Override
        public boolean execute(String s) {
            // 正则表达式,匹配小写字母
            return s.matches("[a-z]+");
        }
    }

    static class IsNumberCaseStrategy implements ValidateStrategy {

        @Override
        public boolean execute(String s) {
            // 正则表达式，匹配数字
            return s.matches("\\d+");
        }
    }
}



